<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style type="text/css">
        #box{
            width: 800px;
            height: 200px;
            border: 3px solid #999;
            margin: 20px auto;
            overflow: scroll;
        }
        #content{
            width: 10000px;
        }
        #imglist{
            float: left;
        }
        #imglist img{
            width: 300px;
            height: 200px;
            float: left;
        }
    </style>
</head>
<body>
    <h1>图片无缝滚动</h1>

    <hr>

    <div id="box">
        <div id="content">
            <div id="imglist">
                <img src="./imgs/Meinv001.jpg">
                <img src="./imgs/Meinv002.jpg">
                <img src="./imgs/Meinv003.jpg">
                <img src="./imgs/Meinv004.jpg">
                <img src="./imgs/Meinv005.jpg">
                <img src="./imgs/Meinv006.jpg">
                <img src="./imgs/Meinv007.jpg">
                <img src="./imgs/Meinv008.jpg">
                <img src="./imgs/Meinv009.jpg">
                <img src="./imgs/Meinv010.jpg">
                <img src="./imgs/Meinv011.jpg">
                <img src="./imgs/Meinv012.jpg">
                <img src="./imgs/Meinv013.jpg">
                <img src="./imgs/Meinv014.jpg">
                <img src="./imgs/Meinv015.jpg">
            </div>
        </div>
    </div>


    <script>
        var width = imglist.offsetWidth;
        // 将所有图片 克隆一份,并追加到当前图片之后
        content.appendChild(imglist.cloneNode(true));
        

        function scrollImage() {
            // 判断一轮图片是否滚完
            if (box.scrollLeft >= width) {
                // 重置滚动条
                box.scrollLeft = 0;
            }
            box.scrollLeft += 1;
            console.log(box.scrollLeft);
        }

        setInterval(scrollImage, 10);
        





    </script>
</body>
</html>

